<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流式布局</title>
</head>

<body>
    <div class="container2">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>
    <style>
        .container2 {
            width: 200px;
            height: 150px;
            display: flex;
            flex-flow: row wrap;
            align-content: flex-start;
        }

        .item {
            box-sizing: border-box;
            background: #eee;
            flex: 0 0 20%;
            height: 40px;
            margin: 5px;
        }
    </style>
</body>

</html>